package com.onluy.frameworkcloud.tools.utils;

import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

public class RequestUtil {

    public static JSONObject getHeaderAdnBaseInfo(HttpServletRequest request)   {
        JSONObject logJson=new JSONObject();
        logJson.put("Method",request.getMethod());
        logJson.put("ContentType",request.getContentType());
        logJson.put("RequestURI",request.getRequestURI());
        logJson.put("IPAddress", HttpIPUtil.getIPAddress(request));
        Enumeration<String> headerNames = request.getHeaderNames();
        while(headerNames.hasMoreElements()){
            String nextElement = headerNames.nextElement();
            logJson.put(nextElement, request.getHeader(nextElement));
        }
        return logJson ;



    }
    
}
